import { forwardRef, Module } from '@nestjs/common';
import { UserService } from './user.service';
import { UserController } from './user.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from '@/modules/system/user/entities/user.entity';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { RoleModule } from '@/modules/system/role/role.module';
import { UserRoleModule } from '@/modules/system/user-role/user-role.module';
import { MenuModule } from '@/modules/system/menu/menu.module';
import { RoleMenuModule } from '@/modules/system/role-menu/role-menu.module';
import { LogModule } from '@/modules/system/log/log.module';
import { UserSubuserModule } from '@/modules/system/user-subuser/user-subuser.module';
import { BaseController } from '@/modules/system/user/base.controller';

@Module({
    imports: [
        TypeOrmModule.forFeature([User]),
        forwardRef(()=>(RoleModule)),
        UserRoleModule,
        MenuModule,
        RoleMenuModule,
        LogModule,
        UserSubuserModule,
        JwtModule.registerAsync({
            imports: [ConfigModule],
            useFactory: async (config: ConfigService) => ({
                secret: config.get('SECRET'),
                signOptions: {
                    expiresIn: config.get('JWT_EXPIRESIN'),
                },
            }),
            inject: [ConfigService],
        }),
    ],
    controllers: [UserController,BaseController],
    providers: [UserService],
    exports: [UserService, TypeOrmModule],
})
export class UserModule {
}
